<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!--
  ~ Copyright (c) 2016 United States Government as represented by the Administrator of the
  ~ National Aeronautics and Space Administration. All Rights Reserved.
  -->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Basic Globe Tutorial</title>
    <script src="file:///android_asset/codemirror-5.16.0/lib/codemirror.js" type="text/javascript"></script>
    <script src="file:///android_asset/codemirror-5.16.0/mode/clike/clike.js" type="text/javascript"></script>
    <script src="file:///android_asset/codemirror-5.16.0/mode/xml/xml.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="file:///android_asset/codemirror-5.16.0/lib/codemirror.css"/>
    <link rel="stylesheet" type="text/css" href="file:///android_asset/override.css"/>
</head>
<body>
<h1>Basic Globe Tutorial</h1>
<p>Demonstrates how to construct a WorldWindow with a few layers.</p>
The globe uses the default navigation gestures:
<ul>
    <li>one-finger pan moves the camera,</li>
    <li>two-finger pinch-zoom adjusts the range to the look at position,</li>
    <li>two-finger rotate arcs the camera horizontally around the look at position,</li>
    <li>three-finger tilt arcs the camera vertically around the look at position.</li>
</ul>
<h2>Get Started</h2>
<p>It’s very easy to get started using World Wind Android. You simply create and configure a <b>WorldWindow</b> View
    object and add it to a layout. This can be performed in an Activity or a Fragment.
</p>
<div style="border-top: 1px solid black; border-bottom: 1px solid black;">
    <textarea id="java-snippet" cols="80" rows="5">
// Create a World Window (a GLSurfaceView)...
WorldWindow wwd = new WorldWindow(getContext());
// ... and add some map layers
wwd.getLayers().addLayer(new BackgroundLayer());
wwd.getLayers().addLayer(new BlueMarbleLandsatLayer());
    </textarea>
</div>
<h2>Example</h2>
<h3>BasicGlobeFragment.java</h3>
<p>In this example, we add WorldWindow to a Fragment's layout in its <b>onCreateView()</b> callback. In our
    <b>createWorldWindow()</b> method, you can see how easy it is to create and configure a WorldWindow.</p>
<div style="border-top: 1px solid black; border-bottom: 1px solid black;">
    <textarea id="java-code">
package gov.nasa.worldwindx;
...
public class BasicGlobeFragment extends Fragment {

    private WorldWindow wwd;

    public BasicGlobeFragment() {
    }

    /**
     * Creates a new WorldWindow (GLSurfaceView) object.
     */
    public WorldWindow createWorldWindow() {
        // Create the World Window (a GLSurfaceView) which displays the globe.
        this.wwd = new WorldWindow(getContext());
        // Setup the World Window's layers.
        this.wwd.getLayers().addLayer(new BackgroundLayer());
        this.wwd.getLayers().addLayer(new BlueMarbleLandsatLayer());
        // Setup the World Window's elevation coverages.
        this.wwd.getGlobe().getElevationModel().addCoverage(new BasicElevationCoverage());
        return this.wwd;
    }

    /**
     * Gets the WorldWindow (GLSurfaceView) object.
     */
    public WorldWindow getWorldWindow() {
        return this.wwd;
    }

    /**
     * Adds the WorldWindow to this Fragment's layout.
     */
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_globe, container, false);
        FrameLayout globeLayout = (FrameLayout) rootView.findViewById(R.id.globe);

        // Add the WorldWindow view object to the layout that was reserved for the globe.
        globeLayout.addView(this.createWorldWindow());

        return rootView;
    }

    /**
     * Resumes the WorldWindow's rendering thread
     */
    @Override
    public void onResume() {
        super.onResume();
        this.wwd.onResume(); // resumes a paused rendering thread
    }

    /**
     * Pauses the WorldWindow's rendering thread
     */
    @Override
    public void onPause() {
        super.onPause();
        this.wwd.onPause(); // pauses the rendering thread
    }
}
    </textarea>
</div>

<h3>layout/fragment_globe.xml</h3>
<p>A FrameLayout hosts the WorldWindow.</p>
<div style="border-top: 1px solid black; border-bottom: 1px solid black;">
    <textarea id="xml-code">
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left|top">

    <!--WorldWindow Globe panel-->
    <FrameLayout
            android:id="@+id/globe"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"/>

    ...
</RelativeLayout>

    </textarea>
</div>

<script type="text/javascript">
      var javaSnippet = CodeMirror.fromTextArea(document.getElementById("java-snippet"), {
        mode: "text/x-java",
        readOnly: true
      });
      var javaEditor = CodeMirror.fromTextArea(document.getElementById("java-code"), {
        lineNumbers: true,
        matchBrackets: true,
        mode: "text/x-java",
        readOnly: true
      });
      var xmlEditor = CodeMirror.fromTextArea(document.getElementById("xml-code"), {
        lineNumbers: true,
        matchBrackets: true,
        mode: "application/xml",
        readOnly: true
      });
</script>
</body>
</html>